<?php

namespace app\modules\frontend\controllers;

use Yii;
//use app\models\shbb_park_product;
use yii\data\SqlDataProvider;
use yii\web\Controller;
use app\models\ProductAuth;
use app\models\Batch;
use yii\data\ActiveDataProvider;

class BatchController extends Controller{

    public function actionIndex($id){ //根据产品的id在批次表中查找所有的批次
        $this->layout='product';

        //$models = Batch::find()->where(['ProID' => $id]);

        $sql="select * from shbb_batch where product_id=$id";

        $models=Batch::findBySql($sql)->all();
        //在批次表中查找属于该产品id的批次
        //var_dump($models);

        // var_dump($dataProvider);
        return $this->render('index',['models'=> $models]); //将数据源传给index视图

    }

}